<?php
class UsersModel extends BaseModel
{
    //自动验证
    protected $_validate = array(
        array('name', 'require', '名称必须！'),
        array('email', 'require', '邮件地址必须！'), array('pwd', 'require', '密码必须！'),
        array('repwd', 'require', '确认密码必须！', self::VALUE_VALIDATE),
        array('email', 'email', '邮箱格式错误！', self::VALUE_VALIDATE),
        array('repwd', 'pwd', '确认密码不一致！', self::VALUE_VALIDATE, 'confirm')
    );
    //自动完成
    protected $_auto = array(
        array('pwd', 'md5', self::MODEL_BOTH, 'function'),
        array('reg_time', 'time', self::MODEL_INSERT, 'function'),
        array('reg_ip', 'get_client_ip', self::MODEL_INSERT, 'function')
    );

    public function getUserList($map = null, $order = 'id DESC')
    {
        $allCount = $this->where($map)->count();
        $Page = $this->getPage($allCount);
        $data = $this->where($map)
                ->limit($Page->firstRow . ',' . $Page->listRows)
                ->order($order)
                ->select();
        return array('data' => $data, 'page' => $Page->show());
    }
}